import {
  getuptoken,
  getMeatList,
  getPurchaseCountInfo,
  getBusinessTypes,
  getPurchaseStatus,
  getChooseDate,
  getProductList,
  getMeatDetail,
  meatSubmit
} from "@/api/purchaseInfo"
export default {
  namespaced: true, // 封闭
  state: {},
  mutations: {},
  getters: {},
  actions: {
    async uptoken(){
      try {
        return await getuptoken()
      } catch (err) {
        console.log(err)
      }
    },


    // 获取所有Meat列表
    async fetchMeatList(context, payload) {
      let { date, businessType, perPage, page } = payload
      try {
        return await getMeatList(date, businessType, perPage, page)
      } catch (err) {
        console.log(err)
      }
    },
    // 获取填报详情
    async getMeatDetail(context, payload) {
      try {
        // return {
        //   animalProductCheckCertificateNumber: "3431119907",
        //   businessName: "杨复姐",
        //   businessPersonInCharge: "杨复姐",
        //   businessType: 1,
        //   meatCheckCertificateNumber: "0001391165",
        //   phone: "15365016223",
        //   purchaseTime: "2019年10月15日",
        //   purchaseType: "猪肉",
        //   redTicket: "http://cailanzi.image.cailanzi001.com/20191015133155_5da559cba6c3c.jpg",
        //   stallName: "鲜肉一区02",
        //   supplierName: "南京下关肉类批发市场",
        //   supplyMarketName: "南京下关肉类批发市场",
        //   transactionNumber: "32011400800000030996",
        //   unifiedSoci0alCreditCode: "92320114MA1QULRB5W",
        // }
        return await getMeatDetail(payload)
      } catch (err) {
        console.log(err)
      }
    },
    // 获取需要手动填报的经营品类
    async fetchBusinessTypes(context, payload) {
      try {
        const data = await getBusinessTypes()
        return data
      } catch (err) {
        console.log(err)
      }
    },
    // 获取获取已/未填报数量
    async fetchPurchaseCountInfo(context, payload) {
      let { date } = payload
      try {
        const data = await getPurchaseCountInfo(date)
        return data
      } catch (err) {
        console.log(err)
      }
    },
    // 查询指定商户购进状态
    async getPurchaseStatus(context, payload) {
      let { businessId } = payload
      try {
        return await getPurchaseStatus(businessId)
      } catch (err) {
        console.log(err)
      }
    },
    // 获取购进日期
    async getChooseDate(context, payload) {
      try {
        return await getChooseDate()
      } catch (err) {
        console.log(err)
      }
    },
    // 获取在售商品列表
    async getProductList(context, payload) {
      let { businessId, typeId } = payload
      try {
        return await getProductList(businessId,typeId)
      } catch (err) {
        console.log(err)
      }
    },

    // 提交填报
    async fetchMeatSubmit(context, payload) {
      try {
        return await meatSubmit(payload)
      } catch (err) {
        console.log(err)
      }
    },


    // 猪肉填报提交


    // 猪肉详情




    // 牛羊肉详情

  }
}
